package com.example.cofeed.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.PayWay;

/**
 * Created by mqwang on 2017/11/28.
 */

public class PayAdapter extends BaseQuickAdapter<PayWay, BaseViewHolder> {
    public PayAdapter() {
        super(R.layout.item_pay_way);
    }

    @Override
    protected void convert(BaseViewHolder helper, PayWay item) {
        ImageView imageView = (ImageView) helper.getView(R.id.icon_iv);
        Glide.with(mContext).load(item.ico).into(imageView);
        helper.setText(R.id.name_tv, item.text);

        if (item.selected == 1) {
            helper.setImageResource(R.id.push_switch, R.mipmap.seltok);
        } else {
            helper.setImageResource(R.id.push_switch, R.mipmap.seltno);
        }

    }


    public void setSelect(PayWay select){
        for (PayWay payWay:mData) {
            payWay.selected = 0;
        }
        if (select.selected == 0) {
            select.selected = 1;
        } else {
            select.selected = 0;
        }
        notifyDataSetChanged();
    }

}
